﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TimeAxis.Admin
{
    public partial class Admin : System.Web.UI.MasterPage
    {
        public string LoginField = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            Common.Web.Cookie cookie = new Common.Web.Cookie();
            string loginUserId = cookie.GetCookie("LoginUserId");
            if (string.IsNullOrEmpty(loginUserId))
            {
                LoginField = "[<a href=\"/Admin/Default.aspx\">登录</a>]&nbsp;&nbsp;[<a href=\"/Admin/Account/Regist.aspx\">注册</a>]";
            }
            else
            {
                DavidDB.ADO.DBManager dbmanager = new DavidDB.ADO.DBManager();
                Interfaces.IUsers iUser = Impls.ImplUsers.GetInstance(dbmanager);
                Models.Users firstUser = iUser.GetList().LastOrDefault();
                LoginField = "欢迎你 " + iUser.GetModel(Convert.ToInt32(loginUserId)).Nickname + " [<a href=\"/Admin/Account/Logout.aspx\">注销</a>]";
                if (loginUserId.Equals(firstUser.Id.ToString()))
                {
                    LoginField += "&nbsp;&nbsp;[<a href=\"/Admin/Manager/Default.aspx\">管理</a>]";
                }
                dbmanager.Commit();
                dbmanager.Dispose();
            }
        }
    }
}